package com.basic.business.memoType.controller;


import java.util.List;
import java.io.IOException;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import com.basic.common.annotation.FileExport;
import com.basic.common.utils.easyExcel.EasyExcelUtils;
import org.springframework.web.bind.annotation.*;
import com.basic.common.annotation.Log;
import com.basic.common.core.controller.BaseController;
import com.basic.common.core.domain.AjaxResult;
import com.basic.common.enums.BusinessType;
import com.basic.business.memoType.domain.TOrdersMemoType;
import com.basic.business.memoType.service.ITOrdersMemoTypeService;
import com.basic.common.core.page.TableDataInfo;

/**
 * 备注类型Controller
 * 
 * @author zhaoxy_jn@163.com
 */
@RestController
@RequestMapping("/business/memoType")
public class TOrdersMemoTypeController extends BaseController
{
    @Resource
    private ITOrdersMemoTypeService tOrdersMemoTypeService;

    /**
     * 查询备注类型列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TOrdersMemoType tOrdersMemoType)
    {
        startPage();
        List<TOrdersMemoType> list = tOrdersMemoTypeService.getList(tOrdersMemoType);
        return getDataTable(list);
    }

    /**
     * 导出备注类型列表
     */
    @PreAuthorize("@ss.hasPermi('business:memoType:export')")
    @Log(title = "备注类型", businessType = BusinessType.EXPORT)
    @FileExport(fileName = "备注类型.xlsx")
    @PostMapping("/export")
    public String export(TOrdersMemoType tOrdersMemoType) throws IOException
    {
        List<TOrdersMemoType> list = tOrdersMemoTypeService.getList(tOrdersMemoType);
        return EasyExcelUtils.excelExport(TOrdersMemoType.class,"备注类型数据", list);
    }

    /**
     * 获取备注类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:memoType:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tOrdersMemoTypeService.get(id));
    }

    /**
     * 新增备注类型
     */
    @PreAuthorize("@ss.hasPermi('business:memoType:add')")
    @Log(title = "备注类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TOrdersMemoType tOrdersMemoType)
    {
        return toAjax(tOrdersMemoTypeService.insert(tOrdersMemoType));
    }

    /**
     * 修改备注类型
     */
    @PreAuthorize("@ss.hasPermi('business:memoType:edit')")
    @Log(title = "备注类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TOrdersMemoType tOrdersMemoType)
    {
        return toAjax(tOrdersMemoTypeService.update(tOrdersMemoType));
    }

    /**
     * 删除备注类型
     */
    @PreAuthorize("@ss.hasPermi('business:memoType:remove')")
    @Log(title = "备注类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tOrdersMemoTypeService.deleteByIds(ids));
    }

    /**
     * 状态变更
     */
    @PreAuthorize("@ss.hasPermi('business:memoType:changeStatus')")
    @Log(title = "备注类型", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeMountStatus(@RequestParam("ids") String[] ids, @RequestParam("status") String status)
    {
        return toAjax(tOrdersMemoTypeService.updateStatusByIds(ids, status));
    }

    /**
     * 刷新缓存
     */
    @PreAuthorize("@ss.hasPermi('business:memoType:refreshCache')")
    @Log(title = "备注类型", businessType = BusinessType.CLEAN)
    @DeleteMapping("/refreshCache")
    public AjaxResult refreshCache()
    {
        tOrdersMemoTypeService.resetMemoTypeCache();
        return success();
    }
}
